package com.funwell.server.constants;

import java.util.ArrayList;
import java.util.List;

public enum SysModuleEnum implements IEnum{
    SYS("SYS", "系统"), // 医院、科室
    BASE("BASE", "基础"), // 广告、字典、意见建议、标准科室、推送等其他
    DOC("DOC", "医生"),
    PAT("PAT", "患者"),
    ADMIN("ADMIN", "管理员"),
    TEAM("TEAM", "团队"),
    FOLLOW("FOLLOW", "医患关系"),
    CONSULT("CONSULT", "咨询"),
    APPOINTMENT("APPOINTMENT", "预约"),
    MEDICAL("MEDICAL", "病历档案"),
    SNS("SNS", "社交"),
    WECHAT("WECHAT", "微信"), // 用户直接发送的微信图片年内容
    ;
    
    private String key;
    private String value;
    
    private SysModuleEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
    
    public String toString() {
        return this.key;
    }
    
    public static SysModuleEnum getByKey(String key) {
        SysModuleEnum[] es = SysModuleEnum.values();
        for (int i = 0; i < es.length; i++) {
            if (es[i].getKey().equals(key))
                return es[i];
        }
        return null;
    }
    
    public static String[] toArray(List<SysModuleEnum> enumList) {
        if (null == enumList || enumList.isEmpty())
            return null;
        String[] status = new String[enumList.size()];
        for (int i = 0; i < enumList.size(); i++) {
            status[i] = enumList.get(i).getKey();
        }
        return status;
    }

    public static List<SysModuleEnum> fromArray(String[] typeNameList) {
        List<SysModuleEnum> enumList = new ArrayList<SysModuleEnum>();
        SysModuleEnum e = null;
        for (int i = 0; i < typeNameList.length; i++) {
            e = getByKey(typeNameList[i]);
            if (null == e) continue;
            enumList.add(e);
            e = null;
        }
        return enumList;
    }
}
